var app;

window.app = app = angular.module('app', ['ngRoute', 'ngResource', 'textAngular', 'mgcrea.ngStrap', 'ngProgress', 'angularFileUpload']);

app.config([
  '$routeProvider', function($routeProvider) {
    return $routeProvider.otherwise({
      redirectTo: '/blog/list'
    });
  }
]);

app.service('progress', [
  '$rootScope', 'ngProgress', function($rootScope, ngProgress) {
    $rootScope.$on('event:request.start', function() {
      ngProgress.reset();
      return ngProgress.start();
    });
    return $rootScope.$on('event:request.end', function() {
      return setTimeout(function() {
        return ngProgress.complete();
      }, 300);
    });
  }
]);

app.config([
  '$httpProvider', function($httpProvider) {
    return $httpProvider.interceptors.push(function($rootScope) {
      return {
        'request': function(config) {
          $rootScope.$broadcast('event:request.start');
          return config;
        },
        'response': function(config) {
          $rootScope.$broadcast('event:request.end');
          return config;
        }
      };
    });
  }
]);

app.controller('NavigationController', [
  '$rootScope', '$scope', '$route', 'ngProgress', 'progress', function($rootScope, $scope, $route, ngProgress, progress) {
    $rootScope.$on('$locationChangeStart', function() {
      return ngProgress.start();
    });
    $rootScope.$on('$locationChangeSuccess', function() {
      var currentPath, _ref;
      currentPath = (_ref = $route.current.originalPath) != null ? _ref.split('/')[1] : void 0;
      $scope.currentMenu = {};
      $scope.currentMenu[currentPath] = 'active';
      return ngProgress.complete();
    });
    return $rootScope.ACTIVITY_STATUS = {
      '0': {
        text: '隐藏',
        color: 'default',
        value: '0'
      },
      '1': {
        text: '开始报名',
        color: 'success',
        value: '1'
      },
      '2': {
        text: '结束',
        color: 'info',
        value: '2'
      },
      '3': {
        text: '取消',
        color: 'danger',
        value: '3'
      }
    };
  }
]);
